#!/bin/sh

##
# Pre-Install / Pre-Upgrade Script for Macintosh BOINC Manager for OS X revised 7/26/18
##

# If we are replacing an earlier GridRepublic installation, fix the data directory name before installing
## We don't customize BOINC Data directory name for branding
## mv -n "/Library/Application Support/GridRepublic Data" "/Library/Application Support/BOINC Data"

# Delete old World Community Grid Skins
##sudo rm -fR /Library/Application\ Support/BOINC\ Data/skins/World\ Community\ Grid/

# Remove any old BOINC Manager and BOINC Screen Saver bundles to guarantee a clean install
if [[-L "/Applications/BOINCManager.app"]]; then
    pathToRealManager=$(readlink -f "/Applications/BOINCManager.app")
    rm -fR "${pathToRealManager}"
fi
rm -fR "/Library/Application Support/BOINCManager.app"  # Usually redundant

 ## If this is a symbolic link, deletes it. Otherwise deletes the actual app
rm -fR "/Applications/BOINCManager.app"
rm -fR "/Library/Screen Savers/BOINCSaver.saver"

# Remove any old "BOINC Manager.mo" files before installing "BOINC-Manager.mo" files (or vice-versa)
rm -fR "/Library/Application Support/BOINC Data/locale/"

# Remove any previous nvc_config.xml file
rm -f "/Library/Application Support/BOINC Data/nvc_config.xml"

exit 0
